package com.suse.jd_system_server.auto.controller;


import com.suse.jd_system_server.auto.entity.Orders;
import com.suse.jd_system_server.auto.empty.Result;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;;
import java.util.List;
import com.suse.jd_system_server.auto.service.OrdersService;
/**
 *@作者:lhj
 *Controller接口
 *@Date:2023/10/18
*/
@RestController
@RequestMapping("/OrdersURL")
@CrossOrigin
public class OrdersController {


	@Autowired
	private OrdersService ordersservice;


	/**
	根据Order_id查询
	*/
	@GetMapping("/selectByOrder_id/{order_id}")
	public Result selectByOrder_id(@PathVariable(value = "order_id") Long order_id){
		return Result.buildSuccess(ordersservice.selectByOrder_id(order_id));
	}


	/**
	根据Order_id更新
	*/
	@PostMapping("/updateByOrder_id")
	public Result updateByOrder_id(@RequestBody Orders demo){
		return Result.buildSuccess(ordersservice.updateByOrder_id( demo));
	}



	/**
	根据Order_id删除
	*/
	@GetMapping("/deleteByOrder_id/{order_id}")
	public Result deleteByOrder_id(@PathVariable(value = "order_id") Long order_id){
		return Result.buildSuccess(ordersservice.deleteByOrder_id(order_id));
	}





	/**
	 insert:(插入)
	*/
	@PostMapping("/insert")
	public Result insert(@RequestBody Orders demo){
		Result.buildSuccess(ordersservice.insert(demo));
		return Result.buildSuccess(demo);
	}



	/**
	 insertOrUpdate(插入或更新(根据主键或唯一索引更新，主键和唯一索引不会改变))
	*/
	@PostMapping("/insertOrUpdate")
	public Result insertOrUpdate(@RequestBody Orders demo){
		return Result.buildSuccess(ordersservice.insertOrUpdate(demo));
	}



	/**
	 insertBath:(批量插入)
	*/
	@PostMapping("/insertBatch")
	public Result insertBatch(@RequestBody List<Orders> list){
		return Result.buildSuccess(ordersservice.insertBatch(list));
	}



	/**
	 insertOrUpdateBatch:(批量插入或更新)
	*/
	@PostMapping("/insertOrUpdateBatch")
	public Result insertOrUpdateBatch(@RequestBody List<Orders> list){
		return Result.buildSuccess(ordersservice.insertOrUpdateBatch(list));
	}



	/**
	 selectList:(根据参数查询集合)
	*/
	@PostMapping("/selectList")
	public Result selectList(@RequestBody Map<String,Object> param){
		return Result.buildSuccess(ordersservice.selectList(param),ordersservice.selectCount(param));
	}



	/**
	 selectCount:(根据集合查询数量)
	*/
	@PostMapping("/selectCount")
	public Result selectCount(@RequestBody Map<String,Object> param){
		return Result.buildSuccess(ordersservice.selectCount(param));
	}



}
